import { useNavigate } from "react-router-dom";

import { CustomerJourneyParams } from "./RouteState.type";

const RouteStatePageFrom = () => {
    const navigate = useNavigate();

    const handleToPageB = () => {
        const params: CustomerJourneyParams = {
            userId: "123",
            userName: "Leslie",
            isVip: true,
            orderIds: [1, 2, 3],
        };
        navigate(`/route-to`, { state: params, replace: false });
    };

    return (
        <div>
            <h1>A页面-发起跳转</h1>
            <button onClick={handleToPageB}>跳转到B页面（路由状态传参）</button>
        </div>
    );
};
export default RouteStatePageFrom;